﻿<?php

class SubjectApp extends BaseApp
{
 
     var $type = 'subject';  
   
    function index()
    {
        
		
		$pa = $_GET['pa'];
		$pa || $pa = $_REQUEST['pa'];
			
 	    $TB_alonepage = &$this->_model('subject'); 	 
	
		$info = $TB_alonepage->oneshow($pa);
		$TB_alonepage->vistnumadd($info['id']);			
		if($info['modue'])
		{
		$module = $info['modue'];
		}else
		{
		$module = 'subject.view.html';
		}		
			
        $module_list_data = & $GLOBALS['SCup']->_get_module_list_data();
        $appidname = array();
        foreach($module_list_data as $key => $value) {
		    $appidname[$value['id']] = $key ;
		}
		unset($module_list_data);
		
		$detail=explode(",",$info['idlist']);
		$table_id = array();
		$data = array();		
		foreach( $detail AS $key=>$value){
		    $detail1=explode("_",$value);
			if (isset($detail1[0]) && isset($detail1[1])) {
			    $table_id[$detail1[0]] .= $detail1[1].","; 
			}
		}
		$db = & get_db();
		foreach ($table_id as $key => $value) {
		    $string = $value.'0';
		    $data[$key] = $db->get_all("SELECT * FROM ".DB_PREFIX."content_".$key." WHERE id IN ($string)"); 
		}

        $this->assign('appidname', $appidname);
        $this->assign('data', $data);			
        $this->assign('view_charset', VIEW_CHARSET);	

        $this->assign('login_icon', $GLOBALS[SCup]->SCup_user_checking);
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
        $this->assign('page_title', $info['title']);
        $this->assign('name', $info['name']);
        $this->assign('page_description', $info['description']);		
        $this->assign('page_keywords', $info['keywords']);	
		$this->assign('content', $info['content']);	
		$this->assign('info', $info);					
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	    $this->assign('site_url',SITE_URL);	
     		
        $this->display($module);		
		
    }

    function lists()
    {
	    $catid = $word ='';
        if(!isset($_GET['catid']))
		{
		$_GET['catid'] = '';
		}					
        if(!isset($_POST['catid']))
		{
		$_POST['catid'] = '';
		}	
		if($_GET['catid'])
		{
	    $catid = $_GET['catid'];		
		}
		if($_POST['catid'])
		{
	    $catid = $_POST['catid'];		
		}
		
        if(!isset($_GET['word']))
		{
		$_GET['word'] = '';
		}					
        if(!isset($_POST['word']))
		{
		$_POST['word'] = '';
		}	
		if($_GET['word'])
		{
	    $word = $_GET['word'];		
		}
		if($_POST['word'])
		{
	    $word = $_POST['word'];		
		}		

		$word_array = explode(' ',$word);
		
		foreach($word_array as $key => $value)
		{
			if(!$value)
			{
             unset($word_array[$key]);
		    }  
		}
	
	
	    $TB_alonepage = &$this->_model('subject'); 	 
		
		$data = $TB_alonepage->show($catid,$word_array,$word);
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);	
  		
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		
		if(!is_array($categorydata))
		{
		 $categorydata = (array)$categorydata;
		}		
		$categorylist = array();
		foreach($categorydata as $value)
		{
		    $categorylist[$value['cat_id']] = $value['cat_name'];
		}	
        $this->assign('categorylist', $categorylist);							
	    
		
        $this->assign('view_charset', VIEW_CHARSET);	

        $this->assign('login_icon', $GLOBALS[SCup]->SCup_user_checking);
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');	
        $this->assign('page_title', $info['title']);
        $this->assign('name', $info['name']);
        $this->assign('page_description', $info['description']);		
        $this->assign('page_keywords', $info['keywords']);	
		$this->assign('content', $info['content']);	
		$this->assign('info', $info);					
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	    $this->assign('site_url',SITE_URL);			
        $this->display('subject_list.view.html');
    }
   
}




?>